package com.hd.trans.network.apiService;



import com.hd.trans.network.ParamJson;
import com.hd.trans.network.bean.AliTokenResponse;
import com.hd.trans.network.bean.DataResponse;
import com.hd.trans.network.bean.LanguageCodeResponse;
import com.hd.trans.network.bean.OCRResponse;
import com.hd.trans.network.bean.RCOcrConvert;
import com.hd.trans.network.bean.RCOcrFileDownload;
import com.hd.trans.network.bean.RCUploadPointPar;
import com.hd.trans.network.bean.TimeResponse;
import com.hd.trans.network.bean.TranslationResponse;

import java.util.Map;

import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.HeaderMap;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Query;


/**
 * Author: yang
 * Date: 2018/11/14 11:03
 * Desc: 网络请求接口
 */
public interface ApiService {


    /**
     * 获取服务器时间戳
     */
    @GET("api/v4/getUTCTime")
    Observable<TimeResponse> getServiceTime();

    /**
     * 获取阿里Token(阿里语音翻译需要)
     */
    @POST("api/v4/getalitoken")
    Observable<AliTokenResponse> getAlitoken(@Body ParamJson.CommonParam param);




    /**
     * 快捷翻译
     */
    @POST("api/v4/quickfanyi")
    Observable<TranslationResponse> translationText(@Body ParamJson.TranslationParam param);


    /**
     * 语种识别
     */
    @POST("api/v4/fanyilanguage")
    Observable<LanguageCodeResponse> getLanguageCode(@Body ParamJson.LanguageParam param);




    /**
     * 照片识别
     */
//    @Headers({"Content-Type: application/octet-stream"})
    @POST("api/v4/quickocr")
//    Observable<DataResponse> photoOCR(@PartMap Map<String, RequestBody> requestBodyMap, @Part MultipartBody.Part file );
    Observable<OCRResponse> photoOCR(@HeaderMap Map<String, Object> headers, @Body RequestBody body);


    /**
     * 上传参数，创建任务
     */
    @POST("api/v4/uploadpar")
    Observable<RCUploadPointPar> uploadParam(@Body RequestBody body);


    /**
     * 上传文件
     */
    @POST("api/v4/uploadfile")
    Observable<DataResponse> uploadFile(
            @Query("tasktag") String tasktag,
            @Query("timestamp") String timestamp,
            @Query("tasktoken") String tasktoken,
            @Query("chunk") int chunk,
            @Query("chunks") int chunks,
            @Query("fileindex") int fileindex,
            @Body RequestBody file
    );

    /**
     * 查询任务状态
     */
    @Headers("Keep-Alive:true")
    @FormUrlEncoded
    @POST("api/v4/taskstate")
    Observable<RCOcrConvert> queryTaskState(
            @Field("tasktag") String tasktag,
            @Field("ifshowtxt") int ifshowtxt,
            @Field("account") String account,
            @Field("usertoken") String usertoken
    );

    @FormUrlEncoded
    @POST("api/v4/taskdown")
    Observable<RCOcrFileDownload> downloadFile(
            @Field("tasktag") String tasktag,
            @Field("account") String account,
            @Field("usertoken") String usertoken,
            @Field("downtype") int downtype,
            @Field("multiurl") int multiurl
    );
}
